package engine.newUi
{
	import engine.GameData;
	import engine.control.loading.MultLoader;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.ResPath;
	import engine.flag.GameDefine;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.tip.TipsMainLogic;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.system.Capabilities;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.window.NxWindowDragType;
	import newx.com.control.window.NxWindowEvent;

	/**
	 *无量玉壁逻辑 
	 * @author gaoyq
	 * 
	 */
	public class WlybLogic
	{
		private var _ui:WlybUI;
		public static var _self:WlybLogic;
		/**数据模型*/
		private 	var _model			:ModelLocator;
		/**当前重***/
		private var WLYBCurFloor:int = 0;
		/**无量玉璧已击杀关卡***/
		private var WLYBDefLevel:int = 0;
		/**当前重的所有关卡**/
		private var curAllLevel:Array;
		/***按照要求的位置把MC排序好的ARR**/
		private var sortMc:Array = [];
		/**当前需要加载的资源路径**/
		private var resArr:Array = [];
		/***玉壁宝箱绑定号***/
		private var WlybBoxIndex:int = -1;
		/***总SWF***/
		private var wlybswf:MovieClip ;
		/***按纽列表***/
		private var _btnListArray:Array;
		private var _checkVIPObj:Object	=	{};
		private var _bindManage		:BindManage;
		private var sprite:Sprite =  new Sprite();
		/**大BOSS显示对象**/
		private var bossItem:MovieClip;
		/***过一重水墨特效**/
		private var levelEff:MovieClip;
		
		private var _play : Boolean;
		public function WlybLogic()
		{
		}
		
		public static function getInstance():WlybLogic
		{
			if(_self == null)
			{
				_self =new WlybLogic();
			}
			return _self;
		}
		
		
		public function uiinit():void
		{
			_model = ModelLocator.getInstance();
			_bindManage		=	BindManage.getInstance();
			
			_checkVIPObj			=	StaticIni.getIniObj("PKListUI_VIP");
			
			ui.windowBG.dragSpaceType = NxWindowDragType.Window_NONE;

			_btnListArray			=	[];
			
			
			_btnListArray.push(ui.kungfu);
			_btnListArray.push(ui.channel);
			_btnListArray.push(ui.strong);
			_btnListArray.push(ui.lineup);
			_btnListArray.push(ui.line);
			_btnListArray.push(ui.pack);
			_btnListArray.push(ui.role);
			
			_model.addEventListener( String(CustomToClientFlag.SERVER_CUSTOMMSG_OPEN_WLYB_UI_AFT_FIGHT_OVER), showHandle );
			_model.addEventListener( String(CustomToClientFlag.SERVER_CUSTOMMSG_OPEN_WLYB_UI), showHandle );
			
			_bindManage.BindProp(_model.scene.Role,"Level",this,"level");
		}
		
		
		
		/**
		 * 人物等 
		 * @param val
		 * 
		 */		
		public function set level(val:int):void
		{
			var index:int =1;
			ui.role.visible	=	true;
			ui.pack.visible	=	true;
			ui.line.visible	=	true;
			ui.lineup.visible	=	true;
			ui.channel.visible	=	true;
			ui.kungfu.visible	=	true;
			ui.strong.visible	=	true;
			
			if(val < _checkVIPObj["Role"])
			{
				ui.role.visible	=	false;
			}
			if(val < _checkVIPObj["pack"])
			{
				ui.pack.visible	=	false;
			}
			if(val < _checkVIPObj["Line"])
			{
				ui.line.visible	=	false;
			}
			if(val < _checkVIPObj["Lineup"])
			{
				ui.lineup.visible	=	false;
			}
			if(val < _checkVIPObj["Channel"])
			{
				ui.channel.visible	=	false;
			}
			if(val < _checkVIPObj["Kungfu"])
			{
				ui.kungfu.visible	=	false;
			}
			if(val < _checkVIPObj["Strong"])
			{
				ui.strong.visible	=	false;
			}
			for(var i:int = 0; i < _btnListArray.length; i++)
			{
				var checkItem:NxButton	=	_btnListArray[i] as NxButton;
				if(checkItem.visible)
				{
					checkItem.x	=	ui.closeBtn.x - (index * 45 +5);
					index++;
				}
			}
		}
		
		
		/**
		 *有特效的返回处理函数 
		 * @param e
		 * 
		 */
		private function showHandle(e:CustomMsgEvent):void
		{
			//在副本场景里 不能打开
			if(GameData.SceneType==GameDefine.SceneType_CS)
			{
				NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000497"))
				return ;
			}
			showUI();
			if(e.pList.length > 0)
			{
				var effid:int = e.pList[0];
				if(effid == 1)
				{//过一关
					if(WLYBDefLevel == 25)
					{
						bossItem.gotoAndStop( 4 );
//						(bossItem.getChildAt(0) as MovieClip).gotoAndPlay( 1 );
					}
				}
				else if(effid == 2)
				{//过一重
//					bossItem.gotoAndPlay(2);
					ui.windowBG.addChild(levelEff)
					levelEff.gotoAndPlay(1);
					levelEff.addFrameScript(levelEff.totalFrames-1,mcastop);
					function mcastop():void
					{
						levelEff.stop();
						if( levelEff.parent != null )
						{
							levelEff.parent.removeChild(levelEff);
						}
					}
				}
				else if(effid == 3)
				{//开宝箱
//					bossItem.gotoAndPlay(2);
				}
			}
		}
		
		public function showUI():void
		{
			resArr = [];
			WLYBCurFloor = _model.scene.Role.GetPropertiesEx("WLYBCurFloor");
			WLYBDefLevel = _model.scene.Role.GetPropertiesEx("WLYBDefLevel");
			curAllLevel = StaticIni.getIniVar("WlybFloor_"+WLYBCurFloor,"levels").split(",");
			for(var i:int = 0;i<curAllLevel.length;i++)
			{
				var picid:String = StaticIni.getIniVar(curAllLevel[i],"Model")
				resArr.push( ResPath.PHOTO + "head_"+ picid + ".png");
			}
//			resArr.push(ResPath.PNG + "Money_2.png");
			resArr.push(ResPath.SWF + "wlyb.swf");
			resArr.push(ResPath.SWF + "wlybeff.swf");
//			resArr = [ResPath.PHOTO + "head_22021025.png" , ResPath.SWF + "wlyb.swf"]
			if(wlybswf == null)
			{
				MultLoader.getInstance().load(resArr,true,loadComplete,null);//[ResPath.PHOTO + "head_22021025.png",ResPath.PNG + "Money_2.png"]
			}else
			{
				loadComplete();
			}
		}
		private function loadComplete():void
		{
			setAllView();
			setBoxLoding();
			ui.show();
			var upnoticeUI:UpNoticeUI =  UpNoticeLogic.getInstance().ui;
			if(upnoticeUI.parent!=null)
			{
				upnoticeUI.parent.setChildIndex(upnoticeUI,upnoticeUI.parent.numChildren-1)
			}
		}
		
		/**
		 *清除事件 
		 * @param item
		 * 
		 */
		private function removeItemEvent(item:MovieClip):void
		{
			item.removeEventListener(MouseEvent.CLICK,onMcClickHandle);
			item.removeEventListener(MouseEvent.MOUSE_OVER,onMcOverHandle);
			item.removeEventListener(MouseEvent.MOUSE_OUT,onMcOutHandle);
			
		}
		
		/**
		 * 添加事件
		 * @param item
		 * 
		 */
		private function addItemEvent(item:MovieClip):void
		{
			item.addEventListener(MouseEvent.CLICK,onMcClickHandle);
			item.addEventListener(MouseEvent.MOUSE_OVER,onMcOverHandle);
			item.addEventListener(MouseEvent.MOUSE_OUT,onMcOutHandle);
		}
		
		private function onOutClickHandle(e:MouseEvent):void
		{
			ui.hide();ui
		}
		
		
		/**
		 *设置宝箱进度条显示 以及宝箱状态
		 * 
		 */
		private function setBoxLoding():void
		{
			if(WLYBDefLevel >= curAllLevel.length)
			{
				wlybswf["jy_0"]["jy_0"] .scaleY = 1;
			}else
			{
				wlybswf["jy_0"]["jy_0"] .scaleY = WLYBDefLevel/curAllLevel.length;
			}
			
			var boxArr:Array = _model.scene.GetRecordEx("WLYBBox").recArr;
			var mc:MovieClip;
			for(var i : int = 0; i < 5; i ++)
			{
				mc = wlybswf["box_"+i];
				mc["lid"] = i+1;
				
				mc.gotoAndStop(1);
				mc.buttonMode = true;
				mc.removeEventListener(MouseEvent.CLICK,onBoxClick);
				mc.removeEventListener(MouseEvent.MOUSE_OVER,onBoxOver);
				mc.removeEventListener(MouseEvent.MOUSE_OUT,onBoxOut);
				mc.addEventListener(MouseEvent.CLICK,onBoxClick);
				mc.addEventListener(MouseEvent.MOUSE_OVER,onBoxOver);
				mc.addEventListener(MouseEvent.MOUSE_OUT,onBoxOut);
				if((i+1) <= boxArr.length)
				{
					mc["status"] = boxArr[i][1];
					mc.visible = true;
					if(boxArr[i][1] == 1)
					{//已经打过
						
						mc.gotoAndStop(3);
					}else
					{//已经付钱
						if(boxArr[i][2] == 1 || WLYBDefLevel == 26)
						{
							mc.gotoAndStop(2);
						}
					}
					
				}else
				{
					mc.visible = false;
				}
			}
		}
		
		private function onBoxOver(e:MouseEvent):void
		{
			TipsMainLogic.instance.showMain(StaticIni.getSwfLangStr("UIString_1000383"));
		}
		
		private function onBoxOut(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
		
		/**
		 *设置所有怪物显示 
		 * 
		 */
		private function setAllView():void
		{
			WLYBCurFloor = _model.scene.Role.GetPropertiesEx("WLYBCurFloor");
			WLYBDefLevel = _model.scene.Role.GetPropertiesEx("WLYBDefLevel");
			curAllLevel = StaticIni.getIniVar("WlybFloor_"+WLYBCurFloor,"levels").split(",");
			//当前怪物的对象
			var curObj:Object;
			//显示容器
			var item:MovieClip;
			if(wlybswf == null)
			{
				wlybswf = MultLoader.getInstance().getSourceByUrl(ResPath.SWF + "wlyb.swf");
				
				levelEff = MultLoader.getInstance().getSourceByUrl(ResPath.SWF + "wlybeff.swf");
			}
			
			bossItem = wlybswf["boss"];
			bossItem.gotoAndStop(1);
			(bossItem.getChildAt(0) as MovieClip).gotoAndStop( 1 );
			
			var bossXpic:NxClip;
			if(bossItem["bossXpic"] == null)
			{
				bossXpic = new NxClip();
				bossXpic.source = ResManager.newResClass("CustomControl_0139");
				bossXpic.visible = false;
				bossXpic.x = 10;
				bossXpic.y = 10;
				bossItem.addChild(bossXpic);
				bossItem["bossXpic"] = bossXpic;
			}else
			{
				bossXpic = bossItem["bossXpic"];
			}
			if(WLYBDefLevel == 26)
			{
				bossXpic.visible = true;
			}else
			{
				bossXpic.visible = false;
			}
			if(WLYBDefLevel == 25)
			{
				bossItem.hit.addEventListener( MouseEvent.MOUSE_OVER, onOver );
				bossItem.hit.addEventListener( MouseEvent.MOUSE_OUT, onOut );
				bossItem.hit.addEventListener( MouseEvent.CLICK, onMcClickHandle );
				bossItem.hit.buttonMode = true;
				
			}else
			{
				bossItem.hit.removeEventListener( MouseEvent.MOUSE_OVER, onOver );
				bossItem.hit.removeEventListener( MouseEvent.MOUSE_OUT, onOut );
				bossItem.hit.removeEventListener( MouseEvent.CLICK, onMcClickHandle );
				bossItem.hit.buttonMode = false;
			}
			
			for(var i:int = 0;i < 25; i ++)
			{
				
//				if(curObj == null)
//				{
//					curObj = {};
//				}
				item = wlybswf["mc_"+(i+1)];// sortMc[i] as MovieClip;//
				removeItemEvent(item);
				curObj = StaticIni.getIniObj(curAllLevel[i]);
				
				//怪物头像
				var pic:NxClip ;
				//叉叉
				var xpic:NxClip;
				//问号
				var qpic:NxClip;
				
				item.mouseChildren = false;
				if(item["pic"] == null)
				{
					pic = new NxClip();
					item.img01.addChild(pic);
					item["pic"] = pic;
				}else
				{
					pic = item["pic"];
				}
				
				
				if(item["xpic"] == null)
				{
					xpic = new NxClip();
					xpic.source = ResManager.newResClass("CustomControl_0139");
					xpic.visible = false;
					xpic.x = 10;
					xpic.y = 10;
					item["img02"].addChild(xpic);
					item["xpic"] = xpic;
				}else
				{
					xpic = item["xpic"]; 
				}
		
				if(item["qpic"] == null)
				{
					qpic = new NxClip();
					qpic.source = ResManager.newResClass("CustomControl_0138");
					qpic.visible = false;
					qpic.x = 40;
					qpic.y = 30;
					if((i+1)%5 == 0)
					{
						qpic.x = 50;
					}
					item.addChild(qpic);
					item["qpic"] = qpic;
				}else
				{
					qpic = item["qpic"]; 
				}

				if(curObj == null)
				{
					curObj = {};
					pic.visible = false;
					qpic.visible = true;
					xpic.visible = false;
					curObj["curStatus"] = 3;
					item.gotoAndStop(3);
					addItemEvent(item);
					item["datas"] = curObj;
					continue;
				}
				
				var picid:String = curObj["Model"];
				pic.source =  ResPath.PHOTO + "head_"+ picid + ".png";
			
				curObj["configid"] = curAllLevel[i];
				
				
//				pic.filters = [];
				item.buttonMode = false;
				xpic.visible = false;
				item.gotoAndStop(1);
				curObj["curStatus"] = 1;
				if(i < WLYBDefLevel)
				{
					xpic.visible = true;
					qpic.visible = false;
					curObj["curStatus"] = 1;
					item.gotoAndStop(1);
					
				}else if(i == WLYBDefLevel)
				{
					pic.visible = true;
					qpic.visible = false;
					item.buttonMode = true;
					
					item.gotoAndStop(1);
					curObj["curStatus"] = 2;
				}else
				{
					pic.visible = false;
					qpic.visible = true;
					item.gotoAndStop(3);
					curObj["curStatus"] = 3;
				}
				setJtStatus(WLYBDefLevel);
				item["datas"] = curObj;
				addItemEvent(item);
			}
			wlybswf["atz"].gotoAndStop(1);
			wlybswf["atz"]["hot"].addEventListener(MouseEvent.CLICK,onFightClickHandle);
			wlybswf["atz"]["hot"].addEventListener(MouseEvent.MOUSE_OVER,onFightOverHandle);
			wlybswf["atz"]["hot"].addEventListener(MouseEvent.MOUSE_OUT,onFightOutHandle);
			wlybswf["atz"]["hot"].buttonMode = true;
			wlybswf["biaoti"].gotoAndStop(WLYBCurFloor);
			wlybswf["txt_2"].text = _model.scene.Role.GetPropertiesEx("Savvy");
			wlybswf["txt_1"].text = _model.scene.Role.GetPropertiesEx("MagicCoin");
			
			
		}
		
		private function onOver( evt : MouseEvent ):void
		{
			if( bossItem.currentFrame != 2 )
			{
				bossItem.gotoAndStop( 2 );
			}
			
			if( !_play )
			{
				( bossItem.getChildAt( 0 ) as MovieClip ).gotoAndPlay( 1 );
				_play = true;
			}
			
		}
		
		private function onOut( evt : MouseEvent ):void
		{
			if( bossItem.currentFrame != 3 )
			{
				bossItem.gotoAndStop( 3 );
			}
			_play = false;
		}
		
		private function onFightClickHandle(e:MouseEvent):void
		{
			if(WLYBDefLevel >=26)
			{
				
				var boxArr:Array = _model.scene.GetRecordEx("WLYBBox").recArr;
				
				for(var i : int = 0; i < 5; i ++)
				{
					if(boxArr[i][1] != 1)
					{//没打过
						WlybBoxFightLogic.getInstance().onshowUI(int(boxArr[i][0]));
						return;
					}
				}
				
			}else
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHALLENGE_WLYB,WLYBCurFloor,WLYBDefLevel+1);	
			}
		}
		
		private function onFightOverHandle(e:MouseEvent):void
		{
			var item:MovieClip = (e.currentTarget as MovieClip).parent as MovieClip;
			item.gotoAndStop(2);
		}
		
		private function onFightOutHandle(e:MouseEvent):void
		{
			var item:MovieClip = (e.currentTarget as MovieClip).parent as MovieClip;
			item.gotoAndStop(1);
		}
		
		/**
		 *
		 *设置箭头状态 
		 * @param WLYBDefLevel
		 * 
		 */
		private function setJtStatus(WLYBDefLevel:int):void
		{
			var curIndex:int = 0;
			if((WLYBDefLevel+1)%5 == 0)
			{
				curIndex = (WLYBDefLevel+1)/5;
			}
			var jtmc:MovieClip;
			for(var i:int = 0;i < 5; i++)
			{
				jtmc = wlybswf["jt_" + (i + 1)] ;
				
				jtmc.gotoAndStop(1);
				if(curIndex == i + 1)
				{
					jtmc.gotoAndPlay(1);
				}
			}
		}
		
		/**
		 *鼠标点击 
		 * @param e
		 * 
		 */
		private function onMcClickHandle(e:MouseEvent):void
		{
			var item:MovieClip = e.currentTarget as MovieClip;
			if( WLYBDefLevel == 25)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHALLENGE_WLYB,WLYBCurFloor,WLYBDefLevel+1);	return;
			}
			var status:int = item["datas"]["curStatus"];
			if(status == 2)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHALLENGE_WLYB,WLYBCurFloor,WLYBDefLevel+1);	
			}
			else if(status == 3)
			{
				NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000387"));
			}else
			{
				NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000388"));		
			}
			
		}
		
		/**
		 *鼠标over
		 * @param e
		 * 
		 */
		private function onMcOverHandle(e:MouseEvent):void
		{
			var item:MovieClip = e.currentTarget as MovieClip;
			item.gotoAndStop(2);
			var obj:Object = e.currentTarget.datas;
			if(obj == null)return;
			var status:int = item["datas"]["curStatus"];
			if(status == 1)
			{
				TipsMainLogic.instance.showMain(StaticIni.getSwfLangStrVar("UIString_1000384",[StaticIni.getSwfLangStr(obj["configid"])]));
			}
			else if(status == 2)
			{
				TipsMainLogic.instance.showMain(StaticIni.getSwfLangStrVar("UIString_1000384",[StaticIni.getSwfLangStr(obj["configid"])]));
			}
			else if(status == 3)
			{
				
			}
			
		}
		
		/**
		 *鼠标out
		 * @param e
		 * 
		 */
		private function onMcOutHandle(e:MouseEvent):void
		{
			var item:MovieClip = e.currentTarget as MovieClip;
			item.gotoAndStop(1);
			var obj:Object = e.currentTarget.datas;
			if(obj==null)return;
			if(obj["curStatus"] == 3)
			{
				item.gotoAndStop(3);
			}else if(obj["curStatus"] == 1)
			{
				item.gotoAndStop(1);
			}
			TipsMainLogic.instance.hide();
		}
		
		private function onClickCloseHandle(e:NxWindowEvent):void
		{
			ui.hide();
		}
		
		
		private function onBoxClick(e:MouseEvent):void
		{
			var mc:MovieClip = e.currentTarget as MovieClip;
			if(mc["status"] == 1)
			{
				NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIString_1000524"));
			}else
			{
				WlybBoxFightLogic.getInstance().onshowUI(int(e.currentTarget.lid));
			}
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHALLENGE_WLYB_BOX,int(e.currentTarget.lid));
		}
		
		
		private function onHelpOverClickHandle(e:MouseEvent):void
		{
			TipsMainLogic.instance.showString(StaticIni.getSwfLangStr("UIString_1000389"));	
		}

		private function onHelpOutClickHandle(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
		
		public function BeforeShow ():void
		{
			addListenter();

			setAllView();
			setBoxLoding();
			sprite.graphics.beginFill(0x000000,1);
			sprite.graphics.drawRect(-Capabilities.screenResolutionX/2,-Capabilities.screenResolutionY/2,
				Capabilities.screenResolutionX*2,Capabilities.screenResolutionY*2);
			sprite.graphics.endFill();
			StageInfo.systemSpace.addChild(sprite);
			ui.addChildAt(sprite,0);
			ui.wlybswfSprite.addChild(wlybswf);
		}
		
		public function AfterHide():void
		{
			removeListenter();
			sprite.graphics.clear();
		}
		
		
		/**
		 *添加监听 
		 * 
		 */
		private function addListenter():void
		{
			ui.btn_out.addEventListener(MouseEvent.CLICK,onOutClickHandle);
			ui.windowBG	.addEventListener(	NxWindowEvent.WINDOW_CLOSE,	onClickCloseHandle);
			ui.btn_help.addEventListener(MouseEvent.MOUSE_OVER,onHelpOverClickHandle);
			ui.btn_help.addEventListener(MouseEvent.MOUSE_OUT,onHelpOutClickHandle);
			addItemListent(ui.closeBtn);
			
			addItemListent(ui.role);
			addItemListent(ui.pack);
			addItemListent(ui.line);
			addItemListent(ui.lineup);
			addItemListent(ui.channel);
			addItemListent(ui.strong);
			addItemListent(ui.kungfu);
			
		}
		
		
		/**
		 * 添加对象事件
		 */
		public function addItemListent(val:DisplayObject):void
		{
			val.addEventListener(MouseEvent.CLICK, btnClickHandle)
//			val.addEventListener(MouseEvent.MOUSE_OVER, btnOverHandle)
//			val.addEventListener(MouseEvent.MOUSE_OUT, outHandle)
		}
		/**
		 * 删除对象事件
		 */
		private function removeItemListent(val:DisplayObject):void
		{
			val.removeEventListener(MouseEvent.CLICK, btnClickHandle)
		}
		
		/**
		 * 按钮事件
		 * @param	e
		 */
		private function btnClickHandle(e:MouseEvent):void
		{
			var obj:DisplayObject	=	e.target as DisplayObject;
			switch (obj) 
			{
				case ui.role:
					MyPropertyLogic.getInstance().ui.showOrHide()
					break;
				case ui.pack:
					PackLogic.getInstance().ui.showOrHide()
					break;
				case ui.strong:
					EquipModifiedUI.getInstance().showOrHide()
					break;
				case ui.closeBtn:

					ui.hide();
					break;
				case ui.line:
					EmbattleLogic.getInstance().ui.showOrHide();
					//UIManage.getInstance().requestOpenUI(SkillUI.getInstance());
					break;
				case ui.lineup:
//					EmbattleLogic.getInstance().ui.showOrHide();
					StatusShopUI.getInstance().showOrHide();
					break;
				case ui.kungfu:
					KungfuPackLogic.getInstance().ui.showOrHide();
					break;
				case ui.channel:
					PulseLogic.getInstance().ui.show();
					break;
				default:
			}
		}
		
		
		/**
		 *移除监听 
		 * 
		 */
		private  function removeListenter():void
		{
			
			ui.btn_out.removeEventListener(MouseEvent.CLICK,onOutClickHandle);
			ui.windowBG	.removeEventListener(	NxWindowEvent.WINDOW_CLOSE,	onClickCloseHandle);
			ui.btn_help.removeEventListener(MouseEvent.MOUSE_OVER,onHelpOverClickHandle);
			ui.btn_help.removeEventListener(MouseEvent.MOUSE_OUT,onHelpOutClickHandle);
			wlybswf["atz"].removeEventListener(MouseEvent.CLICK,onMcClickHandle);
			wlybswf["atz"].removeEventListener(MouseEvent.MOUSE_OVER,onFightOverHandle);
			wlybswf["atz"].removeEventListener(MouseEvent.MOUSE_OUT,onFightOutHandle);
		}
		
		public function get ui():WlybUI
		{
			if(_ui==null)
			{
				_ui	=	new WlybUI();
			}
			return _ui
		}
	}
}